def split_array(array, count)
  raise RuntimeError if count > array.size

  dest = []  # holy dynamic languages...

  unit = array.size / count
  remainder = array.size % count

  src_idx = 0
  for dest_idx in (0...count)
    size = unit
    if remainder > 0
      size += 1
      remainder -= 1
    end

    # for some reason, every language author like to change the established
    # and perfectly readable standards into new ones.
    dest[dest_idx] = array[src_idx,size] # why not start,end
    src_idx += size
  end

  dest
end

def merge_arrays(*arrays)
  return arrays.inject([]) {|merged, current| merged + current }
end